package com.xinshujia.config.authorization;

import org.springframework.stereotype.Component;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author: 野狼上校
 * @create: 2023-06-11  21:38
 * @version: 1.0
 * @description: 数据库中 资源对应的角色信息
 */
@Component
public class MySecurityMetadataSource {
    private Map<String, Set<String>> resourcesMap = new ConcurrentHashMap<>();

    public void addResourcesForUser(String username, Set<String> resources) {
        resourcesMap.put(username, resources);
    }

    public Set<String> getResourcesForUser(String username) {
        return resourcesMap.getOrDefault(username, Collections.emptySet());
    }
}
